<template>
  <div class="app-container">
    <el-card class="box-card">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true"  label-width="88px">
      <el-form-item label="告知单编号" prop="adviseNo">
        <el-input
          v-model="queryParams.adviseNo"
          placeholder="请输入告知单编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="流水号" prop="sequenceNumber">
        <el-input
          v-model="queryParams.sequenceNumber"
          placeholder="请输入流水号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同名称" prop="contractName">
        <el-input
          v-model="queryParams.contractName"
          placeholder="请输入合同名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同编号" prop="contractNo">
        <el-input
          v-model="queryParams.contractNo"
          placeholder="请输入合同编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="M级" prop="security" v-show="showSearch">
        <el-select
          v-model="queryParams.security"
          placeholder="请选择M级"
          clearable
        >
          <el-option
            v-for="dict in dict.type.yh_security_grade"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <!--
      <el-form-item label="日期" prop="riskDate">
        <el-input
          v-model="queryParams.riskDate"
          placeholder="请输入日期"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      -->
      <el-form-item label="联系人" prop="linkman" v-show="showSearch">
        <el-input
          v-model="queryParams.linkman"
          placeholder="请输入联系人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="联系方式" prop="contactInformation" v-show="showSearch">
        <el-input
          v-model="queryParams.contactInformation"
          placeholder="请输入联系方式"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--<el-form-item label="JS代表室" prop="representativeOffice" v-show="showSearch">
        <el-select
          v-model="queryParams.representativeOffice"
          placeholder="请选择JS代表室"
          clearable
        >
          <el-option
            v-for="dict in dict.type.yh_representative_office"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>-->
      <el-form-item label="合同类别" prop="contractType" v-show="showSearch">
        <el-select
          v-model="queryParams.contractType"
          placeholder="请选择合同类别"
          clearable
        >
          <el-option
            v-for="dict in dict.type.yh_contract_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="项目类别" prop="itemClassification" v-show="showSearch">
        <el-select
          v-model="queryParams.itemClassification"
          placeholder="请选择项目类别"
          clearable
        >
          <el-option
            v-for="dict in dict.type.yh_item_classification"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <!--
    <el-form-item label="合同总金额" prop="totalAmount">
      <el-input
        v-model="queryParams.totalAmount"
        placeholder="请输入合同总金额"
        clearable
        @keyup.enter.native="handleQuery"
      />
    </el-form-item>
    <el-form-item label="产品层级" prop="productHierarchy">
      <el-input
        v-model="queryParams.productHierarchy"
        placeholder="请输入产品层级"
        clearable
        @keyup.enter.native="handleQuery"
      />
    </el-form-item>
    <el-form-item label="合同甲方" prop="partyA">
      <el-input
        v-model="queryParams.partyA"
        placeholder="请输入合同甲方"
        clearable
        @keyup.enter.native="handleQuery"
      />
    </el-form-item>
    <el-form-item label="合同乙方" prop="partyB">
      <el-input
        v-model="queryParams.partyB"
        placeholder="请输入合同乙方"
        clearable
        @keyup.enter.native="handleQuery"
      />
    </el-form-item>
    <el-form-item label="承制单位风险管理工作" prop="undertakeRiskManagement">
      <el-input
        v-model="queryParams.undertakeRiskManagement"
        placeholder="请输入承制单位风险管理工作"
        clearable
        @keyup.enter.native="handleQuery"
      />
    </el-form-item>
    <el-form-item label="总体风险评估——质量" prop="assessmentQuality">
      <el-input
        v-model="queryParams.assessmentQuality"
        placeholder="请输入总体风险评估——质量"
        clearable
        @keyup.enter.native="handleQuery"
      />
    </el-form-item>
    <el-form-item label="总体风险评估——进度" prop="assessmentSchedule">
      <el-input
        v-model="queryParams.assessmentSchedule"
        placeholder="请输入总体风险评估——进度"
        clearable
        @keyup.enter.native="handleQuery"
      />
    </el-form-item>
    <el-form-item label="总体风险评估——费用" prop="assessmentCost">
      <el-input
        v-model="queryParams.assessmentCost"
        placeholder="请输入总体风险评估——费用"
        clearable
        @keyup.enter.native="handleQuery"
      />
    </el-form-item>
    <el-form-item label="总体风险评估——售后服务" prop="assessmentService">
      <el-input
        v-model="queryParams.assessmentService"
        placeholder="请输入总体风险评估——售后服务"
        clearable
        @keyup.enter.native="handleQuery"
      />
    </el-form-item>
    <el-form-item label="JDS意见" prop="representativeOfficeOpinion">
      <el-input
        v-model="queryParams.representativeOfficeOpinion"
        placeholder="请输入JDS意见"
        clearable
        @keyup.enter.native="handleQuery"
      />
    </el-form-item>
    <el-form-item label="拟制人" prop="fictitiousPerson">
      <el-input
        v-model="queryParams.fictitiousPerson"
        placeholder="请输入拟制人"
        clearable
        @keyup.enter.native="handleQuery"
      />
    </el-form-item>
    -->
      <br/>
      <div style="text-align: right;">
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </div>
    </el-form>
      <br/>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['module:cjl:inform:add']"
        >新增</el-button>
      </el-col>
    <!--  <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['module:cjl:inform:edit']"
        >修改</el-button>
      </el-col>-->
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['module:cjl:inform:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
          v-hasPermi="['module:cjl:inform:import']"
        >导入</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['module:cjl:inform:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="notificationList" border @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column type="index" label="序号" width="55" :index="indexMethod" align="center" />
      <!--<el-table-column label="序号" align="center" prop="id" width="60"/>-->
      <el-table-column label="告知单编号" align="center" prop="adviseNo" v-if="columns[0].visible"/>
      <el-table-column label="流水号" align="center" prop="sequenceNumber" v-if="columns[1].visible"/>
      <el-table-column label="合同名称" align="center" prop="contractName" v-if="columns[2].visible"/>
      <el-table-column label="合同编号" align="center" prop="contractNo" v-if="columns[3].visible"/>
      <el-table-column label="M级" align="center" prop="security" v-if="columns[4].visible">
      <template slot-scope="scope">
        <dict-tag :options="dict.type.yh_security_grade" :value="scope.row.security"/>
      </template>
      </el-table-column>
      <el-table-column label="日期" align="center" prop="riskDate" v-if="columns[5].visible"/>
      <el-table-column label="联系人" align="center" prop="linkman" v-if="columns[6].visible"/>
      <el-table-column label="联系方式" align="center" prop="contactInformation" v-if="columns[7].visible"/>
      <el-table-column label="JS代表室" align="center" prop="representativeOffice" v-if="columns[8].visible">
      <template slot-scope="scope">
        <dict-tag :options="dict.type.yh_representative_office" :value="scope.row.representativeOffice"/>
      </template>
      </el-table-column>
      <el-table-column label="合同类别" align="center" prop="contractType" v-if="columns[9].visible">
      <template slot-scope="scope">
        <dict-tag :options="dict.type.yh_contract_type" :value="scope.row.contractType"/>
      </template>
      </el-table-column>
      <el-table-column label="项目类别" align="center" prop="itemClassification" v-if="columns[10].visible">
      <template slot-scope="scope">
        <dict-tag :options="dict.type.yh_item_classification" :value="scope.row.itemClassification"/>
      </template>
      </el-table-column>
      <el-table-column label="合同总金额" align="center" prop="totalAmount" v-if="columns[11].visible"/>
      <el-table-column label="产品层级" align="center" prop="productHierarchy" v-if="columns[12].visible"/>
      <el-table-column label="合同甲方" align="center" prop="partyA" v-if="columns[13].visible"/>
      <el-table-column label="合同乙方" align="center" prop="partyB" v-if="columns[14].visible"/>
      <el-table-column label="承制单位风险管理工作" align="center" prop="undertakeRiskManagement" v-if="columns[15].visible"/>
      <el-table-column label="总体风险评估——质量" align="center" prop="assessmentQuality" v-if="columns[16].visible"/>
      <el-table-column label="总体风险评估——进度" align="center" prop="assessmentSchedule" v-if="columns[17].visible"/>
      <el-table-column label="总体风险评估——费用" align="center" prop="assessmentCost" v-if="columns[18].visible"/>
      <el-table-column label="总体风险评估——售后服务" align="center" prop="assessmentService" v-if="columns[19].visible"/>
      <el-table-column label="JDS意见" align="center" prop="representativeOfficeOpinion" v-if="columns[20].visible"/>
      <el-table-column label="拟制人" align="center" prop="fictitiousPerson" v-if="columns[21].visible"/>
      <el-table-column label="风险通知单类型" align="center" prop="riskNoticeType" v-if="columns[22].visible"/>
      <el-table-column label="备注" align="center" prop="remark" v-if="columns[23].visible"/>
      <el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width" fixed="right">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['module:cjl:inform:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleDelete(scope.row)"
            v-hasPermi="['module:cjl:inform:remove']"
          >删除</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleView(scope.row,scope.index)"
            v-hasPermi="['module:cjl:inform:view']"
          >详细</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    </el-card>
    <!-- 添加或修改风险告知单对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1200px" append-to-body  :close-on-click-modal="false">
      <el-form ref="form" :model="form" :rules="rules" label-width="150px">
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">监管任务信息</p>
            </el-divider>
          </el-header>
          <el-main>
        <el-row>
          <!--<el-col :span="8">
        <el-form-item label="告知单编号" prop="adviseNo">
          <el-input v-model="form.adviseNo" placeholder="请输入告知单编号"  style="width: 100%"  clearable/>
        </el-form-item>
          </el-col>-->
          <el-col :span="8">
        <el-form-item label="流水号" prop="sequenceNumber">
          <el-autocomplete
            clearable
            v-model="form.sequenceNumber"
            placeholder="请输入流水号"
            style="width: 100%"
            :fetch-suggestions="querySearchAsync"
            @select="handleSelect"
          >
          </el-autocomplete>
         <!-- <el-input v-model="form.sequenceNumber" placeholder="请输入流水号"  style="width: 100%"/>-->
        </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="JS代表室" prop="representativeOffice">
              <el-select v-model="form.representativeOffice" placeholder="请选择JS代表室" style="width: 100%" clearable>
                <el-option
                  v-for="dict in dict.type.yh_representative_office"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            <!--  <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择JS代表室" />-->
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="合同编号" prop="contractNo">
              <el-input v-model="form.contractNo" placeholder="请输入合同编号"  style="width: 100%"  clearable/>
            </el-form-item>
          </el-col>
        </el-row>
            <el-row>
         <!-- <el-col :span="8">
            <el-form-item label="合同名称" prop="contractName">
              <el-input v-model="form.contractName" placeholder="请输入合同名称"  style="width: 100%"  clearable/>
            </el-form-item>
          </el-col>-->
    <!--      <el-col :span="8">
        <el-form-item label="日期" prop="riskDate">
          <el-date-picker
            clearable
            style="width: 100%"
            v-model="form.riskDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请输入日期">
          </el-date-picker>
        </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
        <el-form-item label="联系人" prop="linkman">
          <el-input v-model="form.linkman" placeholder="请输入联系人"  style="width: 100%"  clearable/>
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item label="联系方式" prop="contactInformation">
          <el-input v-model="form.contactInformation" placeholder="请输入联系方式"  style="width: 100%"  clearable/>
        </el-form-item>
          </el-col>-->
          <el-col :span="8">
            <el-form-item label="M级" prop="security">
              <el-select v-model="form.security" placeholder="请选择M级" style="width: 100%"  clearable>
                <el-option
                  v-for="dict in dict.type.yh_security_grade"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item label="合同类别" prop="contractType">
          <el-select v-model="form.contractType" placeholder="请选择合同类别" style="width: 100%"  clearable>
            <el-option
              v-for="dict in dict.type.yh_contract_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
          </el-col>
            <el-col :span="8">
              <el-form-item label="项目类别" prop="itemClassification">
                <el-select v-model="form.itemClassification" placeholder="请选择项目类别" style="width: 100%"  clearable>
                  <el-option
                    v-for="dict in dict.type.yh_item_classification"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
               <!-- <el-input v-model="form.itemClassification" placeholder="请输入项目类别" />-->
              </el-form-item>
            </el-col>
            </el-row>
          </el-main>
        </el-container>
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">风险告知单信息</p>
            </el-divider>
          </el-header>
          <el-main>
        <el-row>
          <el-col :span="8">
            <el-form-item label="告知单编号" prop="adviseNo">
              <el-input v-model="form.adviseNo" placeholder="请输入告知单编号"  style="width: 100%"  clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="合同名称" prop="contractName">
              <el-input v-model="form.contractName" placeholder="请输入合同名称"  style="width: 100%"  clearable/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item label="合同总金额" prop="totalAmount">
          <el-input v-model="form.totalAmount" placeholder="请输入合同总金额"  style="width: 100%"  clearable/>
        </el-form-item>
          </el-col>
        </el-row>
          <el-row>
          <el-col :span="8">
            <el-form-item label="日期" prop="riskDate">
              <el-date-picker
                clearable
                style="width: 100%"
                v-model="form.riskDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请输入日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
              <el-col :span="8">
                <el-form-item label="联系人" prop="linkman">
                  <el-input v-model="form.linkman" placeholder="请输入联系人"  style="width: 100%"  clearable/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="联系方式" prop="contactInformation">
                  <el-input v-model="form.contactInformation" placeholder="请输入联系方式"  style="width: 100%"  clearable/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
          <el-col :span="8">
        <el-form-item label="产品层级" prop="productHierarchy">
          <el-input v-model="form.productHierarchy" placeholder="请输入产品层级"  style="width: 100%"  clearable/>
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item label="合同甲方" prop="partyA">
          <el-input v-model="form.partyA" placeholder="请输入合同甲方"  style="width: 100%"  clearable/>
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item label="合同乙方" prop="partyB">
          <el-input v-model="form.partyB" placeholder="请输入合同乙方"  style="width: 100%"  clearable/>
        </el-form-item>
          </el-col>
        </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="拟制人" prop="fictitiousPerson">
                  <el-input v-model="form.fictitiousPerson" placeholder="请输入拟制人"  style="width: 100%"  clearable/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="风险通知单类型" prop="riskNoticeType">
                  <el-input v-model="form.riskNoticeType" placeholder="请输入风险通知单类型"  style="width: 100%"  clearable />
                </el-form-item>
              </el-col>
            </el-row>
            <el-form-item label="风险管理工作" prop="undertakeRiskManagement">
              <el-input v-model="form.undertakeRiskManagement" type="textarea" placeholder="请输入承制单位风险管理工作"  style="width: 100%"  maxlength="100"/>
            </el-form-item>
            <el-form-item label="JDS意见" prop="representativeOfficeOpinion">
              <el-input v-model="form.representativeOfficeOpinion" type="textarea" placeholder="请输入JDS意见"  maxlength="100"/>
            </el-form-item>
          </el-main>
        </el-container>
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">总体风险评估</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="8">
                <el-form-item label="质量" prop="assessmentQuality">
                  <el-input v-model="form.assessmentQuality" placeholder="请输入质量"  style="width: 100%"  clearable/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="进度" prop="assessmentSchedule">
                  <el-input v-model="form.assessmentSchedule" placeholder="请输入进度"  style="width: 100%"  clearable/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="费用" prop="assessmentCost">
                  <el-input v-model="form.assessmentCost" placeholder="请输入费用"  style="width: 100%"  clearable/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="售后服务" prop="assessmentService">
                  <el-input v-model="form.assessmentService" placeholder="请输入售后服务"  style="width: 100%"  clearable/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" maxlength="500"/>
            </el-form-item>
          </el-main>
        </el-container>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 用户导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的风险告知单数据
          </div>
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="danger" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 查看风险告知单信息对话框 -->
    <el-dialog :title="view.title" :visible.sync="view.open" width="1350px" append-to-body :close-on-click-modal="false">
      <el-form ref="form" :model="form" :rules="rules" label-width="190px">
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">风险告知单基本信息</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="8">
                <el-form-item label="告知单编号" prop="adviseNo">
                  <el-input v-model="form.adviseNo"   style="width: 100%" readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="流水号" prop="sequenceNumber">
                  <el-input v-model="form.sequenceNumber"   style="width: 100%"/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="JS代表室" prop="deptId">
                  <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true"  disabled="true"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="合同编号" prop="contractNo">
                  <el-input v-model="form.contractNo"   style="width: 100%" readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="合同名称" prop="contractName">
                  <el-input v-model="form.contractName"   style="width: 100%" readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="日期" prop="riskDate" >
                  <el-date-picker
                    clearable
                    style="width: 100%"
                    v-model="form.riskDate"
                    type="date"
                    value-format="yyyy-MM-dd"
                    readonly="true"
                    >
                  </el-date-picker>
                  <!--<el-input v-model="form.riskDate" placeholder="请输入日期" />-->
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="联系人" prop="linkman">
                  <el-input v-model="form.linkman"   style="width: 100%" readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="联系方式" prop="contactInformation">
                  <el-input v-model="form.contactInformation"  style="width: 100%" readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="M级" prop="security">
                  <el-select v-model="form.security"  style="width: 100%" disabled="true">
                    <el-option
                      v-for="dict in dict.type.yh_security_grade"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                  <!--<el-input v-model="form.security" placeholder="请输入M级" />-->
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="合同类别" prop="contractType">
                  <el-select v-model="form.contractType"  style="width: 100%" disabled="true">
                    <el-option
                      v-for="dict in dict.type.yh_contract_type"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="项目类别" prop="itemClassification">
                  <el-select v-model="form.itemClassification"  style="width: 100%" disabled="true">
                    <el-option
                      v-for="dict in dict.type.yh_item_classification"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </el-main>
        </el-container>
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">风险告知单合同信息</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="8">
                <el-form-item label="合同总金额" prop="totalAmount">
                  <el-input v-model="form.totalAmount"   style="width: 100%" readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="产品层级" prop="productHierarchy">
                  <el-input v-model="form.productHierarchy"  style="width: 100%" readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="合同甲方" prop="partyA">
                  <el-input v-model="form.partyA"   style="width: 100%" readonly="true"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="合同乙方" prop="partyB">
                  <el-input v-model="form.partyB"   style="width: 100%" readonly="true"/>
                </el-form-item>
              </el-col>
            </el-row>
          </el-main>
        </el-container>
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">风险告知单风险信息</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="8">
                <el-form-item label="承制单位风险管理工作" prop="undertakeRiskManagement">
                  <el-input v-model="form.undertakeRiskManagement"   style="width: 100%" readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="总体风险评估——质量" prop="assessmentQuality">
                  <el-input v-model="form.assessmentQuality"  style="width: 100%" readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="总体风险评估——进度" prop="assessmentSchedule">
                  <el-input v-model="form.assessmentSchedule"   style="width: 100%" readonly="true"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="总体风险评估——费用" prop="assessmentCost">
                  <el-input v-model="form.assessmentCost"  style="width: 100%" readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="总体风险评估——售后服务" prop="assessmentService">
                  <el-input v-model="form.assessmentService"  style="width: 100%" readonly="true"/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="拟制人" prop="fictitiousPerson">
                  <el-input v-model="form.fictitiousPerson"   style="width: 100%" readonly="true"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="风险通知单类型" prop="riskNoticeType">
                  <el-input v-model="form.riskNoticeType"   style="width: 100%" readonly="true"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-form-item label="JDS意见" prop="representativeOfficeOpinion">
              <el-input v-model="form.representativeOfficeOpinion" type="textarea"   readonly="true"/>
            </el-form-item>
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" type="textarea"  readonly="true"/>
            </el-form-item>
          </el-main>
        </el-container>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="viewCancel">返 回</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listNotification, getNotification, delNotification, addNotification, updateNotification } from "@/api/module/cjl/inform";
import { getToken } from "@/utils/auth";
import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import watermark from "watermark-dom";
import { listSearchContract} from "@/api/module/cjl/contract";
export default {
  name: "Notification",
  dicts: ['yh_security_grade','yh_representative_office','yh_contract_type','yh_item_classification'],
  components: { Treeselect },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: false,
      // 总条数
      total: 0,
      // 部门树选项
      deptOptions: undefined,
      // 风险告知单表格数据
      notificationList: [],
      // 合同台账表格数据
      contractList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        adviseNo: null,
        sequenceNumber: null,
        contractName: null,
        contractNo: null,
        security: null,
        riskDate: null,
        linkman: null,
        contactInformation: null,
        representativeOffice: null,
        contractType: null,
        itemClassification: null,
        totalAmount: null,
        productHierarchy: null,
        partyA: null,
        partyB: null,
        undertakeRiskManagement: null,
        assessmentQuality: null,
        assessmentSchedule: null,
        assessmentCost: null,
        assessmentService: null,
        representativeOfficeOpinion: null,
        fictitiousPerson: null,
        riskNoticeType: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        note6: null,
        note7: null,
        note8: null,
        note9: null,
        note10: null,
        orderByColumn:"createTime",
        isAsc:"desc"
      },
      // 表单参数
      form: {},
      // 用户查询参数
      view:{
        // 是否显示弹出层（用户查询）
        open: false,
        // 弹出层标题（用户查询）
        title: "",
      },
      // 用户导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/module/cjl/inform/importData"
      },
      // 列信息
      columns: [
        { key: 0, label: `告知单编号`, visible: true },
        { key: 1, label: `流水号`, visible: true },
        { key: 2, label: `合同名称`, visible: true },
        { key: 3, label: `合同编号`, visible: true },
        { key: 4, label: `M级`, visible: true },
        { key: 5, label: `日期`, visible: false },
        { key: 6, label: `联系人`, visible: false},
        { key: 7, label: `联系方式`, visible: false },
        { key: 8, label: `JS代表室`, visible: false },
        { key: 9, label: `合同类别`, visible: true },
        { key: 10, label: `项目类别`, visible: false},
        { key: 11, label: `合同总金额`, visible: false },
        { key: 12, label: `产品层级`, visible: false },
        { key: 13, label: `合同甲方`, visible: false },
        { key: 14, label: `合同乙方`, visible: false},
        { key: 15, label: `承制单位风险管理工作`, visible: false},
        { key: 16, label: `总体风险评估——质量`, visible: false },
        { key: 17, label: `总体风险评估——进度`, visible: false},
        { key: 18, label: `总体风险评估——费用`, visible: false},
        { key: 19, label: `总体风险评估——售后服务`, visible: false},
        { key: 20, label: `JDS意见`, visible: false},
        { key: 21, label: `拟制人`, visible: false},
        { key: 22, label: `风险通知单类型`, visible: false},
        { key: 23, label: `备注`, visible: false }
      ],
      // 表单校验
      rules: {
        adviseNo: [
          { required: true, message: "告知单编号不能为空", trigger: "blur" },
        ],
       /* sequenceNumber: [
          { required: true, message: "流水号不能为空", trigger: "blur" },
        ],*/
        representativeOffice: [
          { required: true, message: "JS代表室不能为空", trigger: "blur" },
        ],
        /*contractNo: [
          { required: true, message: "合同编号不能为空", trigger: "blur" },
        ],*/
        /*deptId: [
          { required: true, message: "JS代表室不能为空", trigger: "blur" },
        ],*/
      }
    };
  },
  mounted() {
    watermark.load({ watermark_txt: "  "   });
  },
  created() {
    this.getList();
    this.getTreeselect();
    this.getContractInfo();
  },
  methods: {
    /** 查询合同台账列表 */
    getContractInfo() {
      listSearchContract().then(response => {
        this.contractList = response.rows;
      });
    },
    querySearchAsync(queryString, cb) {
      //因为autocomplete只识别value字段,所以用replace(/需要用的字段/g,"value")，将需要用的字段全部替换成value
      //(/***/g 是全部替换，如果不用全部替换，可以参考https://www.w3school.com.cn/jsref/jsref_replace.asp)
      let contractInfoJson= JSON.parse(JSON.stringify(this.contractList).replace(/sequenceNumber/g,"value"));
      let results = queryString ? contractInfoJson.filter(this.createStateFilter(queryString)) : contractInfoJson;
      clearTimeout(this.timeout);
      this.timeout = setTimeout(() => {
        cb(results);
      }, 0.5*1000);
    },
    //根据输入的字段进行筛选
    createStateFilter(queryString) {
      return (state) => {
        return (state.value.toString().toLowerCase().indexOf(queryString.toLowerCase()) === 0);
      };
    },
    //将其他数据自动补全，采用覆盖的方法
    handleSelect(item){
      this.form.sequenceNumber = item.value;
      this.form.contractNo=item.contractNo;
      this.form.contractType=item.contractType;
      this.form.itemClassification=item.projectType;
      this.form.security=item.security;
      this.form.representativeOffice=item.representativeOffice;
    },
    indexMethod(index) {
      index = (index + 1) + (this.queryParams.pageNum - 1) * this.queryParams.pageSize
      return index
    },
    /** 查询风险告知单列表 */
    getList() {
      this.loading = true;
      listNotification(this.queryParams).then(response => {
        this.notificationList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 查询部门下拉树结构 */
    getTreeselect() {
      treeselect().then(response => {
        this.deptOptions = response.data;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 取消按钮
    viewCancel() {
      this.view.open = false;
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        adviseNo: null,
        sequenceNumber: null,
        contractName: null,
        contractNo: null,
        security: null,
        riskDate: null,
        linkman: null,
        contactInformation: null,
        representativeOffice: null,
        contractType: null,
        itemClassification: null,
        totalAmount: null,
        productHierarchy: null,
        partyA: null,
        partyB: null,
        undertakeRiskManagement: null,
        assessmentQuality: null,
        assessmentSchedule: null,
        assessmentCost: null,
        assessmentService: null,
        representativeOfficeOpinion: null,
        fictitiousPerson: null,
        riskNoticeType: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        note6: null,
        note7: null,
        note8: null,
        note9: null,
        note10: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.is=selection.map(item => item.adviseNo)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加风险告知单";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getNotification(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改风险告知单";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateNotification(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addNotification(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 详细按钮操作 */
    handleView(row) {
      /*const id = row.id || this.ids
      getNotification(id).then(response => {
        this.form = response.data;
        this.view.open = true;
        this.view.title = "查看风险告知单信息";
      });*/
      const id = row.id;
      this.$router.push({ path:"/hetong/inform_detail", query: {id}});
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      const i=row.adviseNo || this.is;
      this.$modal.confirm('是否确认删除告知单编号为"' + i + '"的数据项？').then(function() {
        return delNotification(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('module/cjl/inform/export', {
        ...this.queryParams
      }, `notification_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "风险告知单信息导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('module/cjl/inform/importTemplate', {
      }, `inform_template_${new Date().getTime()}.xlsx`)
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    }
  }
};
</script>
<style>
  .el-header, .el-footer {
    background-color: #FFFFFF;
    color: #333;
    text-align: left;
    line-height: 60px;
    font-style: oblique;

  }

  .el-aside {
    background-color: #D3DCE6;
    color: #333;
    text-align: center;
    line-height: 200px;
  }

  body > .el-container {
    margin-bottom: 40px;
  }

  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }

  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }

  /*对话框标题样式*/
  .el-dialog__title{
    /*color: #1ab394;*/
    font-weight: bold;
    font-size: 25px;
  }
</style>
